
package uestc.bitman.edxapp.units;

import uestc.bitman.edxapp.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class VideoBlock extends CourseBlock {

    private String mVideoTitle;

    private String mVideoUrl;

    private String mVideoTrackUrl;

    public void setVideoUrl(String url) {
        mVideoUrl = url;
    }

    public void setVideoTitle(String title) {
        mVideoTitle = title;
    }

    public void setVideoTrackUrl(String trackUrl) {
        mVideoTrackUrl = trackUrl;
    }

    @Override
    public View getContentView(Context context) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.video_block_child, null);
        VideoPlayerWebView webView = (VideoPlayerWebView) view
                .findViewById(R.id.webview_video_player);
        webView.setVideoUrl(mVideoUrl);
        webView.setVideoTrackUrl(mVideoTrackUrl);
        webView.playVideo();
        return view;
    }

    @Override
    public View getTitleView(Context context) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.video_block_parent, null);
        TextView tvTitle = (TextView) view.findViewById(R.id.parent_video_title);
        tvTitle.setText(mVideoTitle);
        return view;
    }
}
